//
//  YWUserTool.m
//  网易新闻
//
//  Created by Yeewii@hotmail.com on 16/6/21.
//  Copyright © 2016年 Yeewii@hotmail.com. All rights reserved.
//

#import "YWUserTool.h"

@implementation YWUserTool



+(id)GetYWObjectForKey:(NSString *)key;
{
   return  [[NSUserDefaults standardUserDefaults]objectForKey:key];
}
+(void)SetYWObject:(id)object forKey:(NSString *)key;
{
    [[NSUserDefaults standardUserDefaults] setObject:object forKey:key];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+(void)isLogin:(void(^)(YWWeChatModel *mod))handle;
{
    if ([self GetYWObjectForKey:@"openid"])
    {
        YWWeChatModel *mod = [YWWeChatModel new];
        mod.country        = [self GetYWObjectForKey:@"country"];
        mod.headimgurl     = [self GetYWObjectForKey:@"headimgurl"];
        mod.nickname       = [self GetYWObjectForKey:@"nickname"];
        mod.openid         = [self GetYWObjectForKey:@"openid"];
        mod.sex            = [self GetYWObjectForKey:@"sex"];
        if (handle)
        {
            handle(mod);
        }
        
    }
}

@end
